package com.codedancer.campus.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codedancer.campus.common.core.BaseMapper;
import com.codedancer.campus.po.ContactAdminChatRoom;
import com.codedancer.campus.qo.contactAdmin.ContactAdminChatRoomPageSearchQo;

public interface ContactAdminChatRoomMapper extends BaseMapper<ContactAdminChatRoom> {
    /**
     * 获取和某个管理员的聊天室
     *
     * @param currentLoginUuid
     * @param adminUuid
     * @return
     */
    default ContactAdminChatRoom getChatRoom(String currentLoginUuid, String adminUuid) {
        LambdaQueryWrapper<ContactAdminChatRoom> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ContactAdminChatRoom::getUserUuid, currentLoginUuid);
        lambdaQueryWrapper.eq(ContactAdminChatRoom::getAdminUuid, adminUuid);
        return selectOne(lambdaQueryWrapper);
    }

    /**
     * 分页获取联系管理员聊天室
     *
     * @param contactAdminChatRoomPage
     * @param contactAdminChatRoomPageSearchQo
     * @return
     */
    default IPage<ContactAdminChatRoom> pageChatRoom(Page<ContactAdminChatRoom> contactAdminChatRoomPage, ContactAdminChatRoomPageSearchQo contactAdminChatRoomPageSearchQo) {
        LambdaQueryWrapper<ContactAdminChatRoom> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ContactAdminChatRoom::getAdminUuid, contactAdminChatRoomPageSearchQo.getCurrentAdminUuid());
        return selectPage(contactAdminChatRoomPage, lambdaQueryWrapper);
    }
}
